#include<unistd.h>
#include<iostream>

int main()
{
    int pipefd[2]={0};
    int n = pipe(pipefd);
    pid_t id = fork();
    if(id<0)
    {
        perror("fork fail");
    }
    if(id == 0)
    {
        char buf[] ="落霞与孤鹜齐飞，秋水共长天一色";
        write(pipefd[1],buf,sizeof(buf));
        _exit(0);
    }
    else if(id>0)
    {
        wait();
        char str[50] = {0};
        read(pipefd[0],str,sizeof(str));
        std::cout<<str<<std::endl;
        
    }
    return 0;
}